package com.fanqwz.hexieshe.domain.usercase;

import com.fanqwz.hexieshe.domain.HeadLine;
import com.fanqwz.hexieshe.domain.executor.PostExecutionThread;
import com.fanqwz.hexieshe.domain.repository.Repository;

import java.util.List;
import java.util.concurrent.Executor;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * Created by fanqw on 2017/6/29.
 */

public class GetHeadLinesUseCase extends UseCase<List<HeadLine>, GetHeadLinesUseCase.Params> {
    private final Repository repository;

    @Inject
    GetHeadLinesUseCase(Repository repository, Executor threadExecutor, PostExecutionThread postExecutionThread) {
        super(threadExecutor, postExecutionThread);
        this.repository = repository;
    }

    @Override
    Observable<List<HeadLine>> buildUseCaseObservable(Params params) {
        return repository.headlines(params.page, params.category, params.tag);
    }

    public static class Params {
        public int page;
        public String category;
        public String tag;

        public Params(int page, String category, String tag) {
            this.page = page;
            this.category = category;
            this.tag = tag;
        }
    }
}
